module.exports = {
  // operPre(callback) {
  //   if (uni.getStorageSync("token")) {
  //     callback();
  //   } else {
  //     uni.showToast({
  //       icon: "none",
  //       title: "请先登录",
  //     });
  //   }
  // },
  loginPrefix() {
    return new Promise((resolve, reject) => {
      if (uni.getStorageSync("token")) {
        resolve();
      } else {
        uni.showToast({
          icon: "none",
          title: "请先登录",
          success: () => {
            setTimeout(() => {
              let pages = getCurrentPages();
              console.log('页面栈',pages)
              let cur = pages[pages.length - 1].route;
              if (cur != "/pages/tabs/my/my") {
                uni.switchTab({
                  url: "/pages/tabs/my/my",
                  fail:error=>{
                    console.log('页面跳转失败',error)
                  }
                });
              }
            }, 1500);
          },
        });
      }
    });
  },
};
